Happiness
Happiness is the state of citizens of a city which defines how well they feel and how well they are going to work. There are four potential happiness states: content, happy, unhappy and angry. Only workers that are working tiles change their mood due to happiness effects, specialists are always content. You can examine happiness of citizens in your or an investigated city in the top line of citizens icons of the main tab of the city dialog; more thorough inspection is possible on special "Happiness" tab. The following article discloses general technical details of happiness. For a more specific description dedicated mostly to the Classic ruleset, consult the article Cities. Basic concepts As it was said before, workers have four levels of happiness: happy, content, unhappy and angry; the last category can be turned off by parameters.angry_citizens from game.ruleset, then the citizens that would be angry will be just unhappy. Unhappy and angry citizens still work, but if they outnumber happy citizens in their city (angry ones counted twice!), the city is thrown into disorder: generates no surplus food, gold or production (but pollutes the environment) and can in a while overthrow some governments for the entire nation. (It was planned to make disorder effects for a city adjustable by the ruleset.) But if there is no unhappy or angry citizens and at least half of the full populaton are happy workers, the city (if its total population is at least parameters.celebrate_size_limit) starts to celebrate that usually brings some bonus to the city. Happiness has some other effects, e.g. if one incites a city it costs much more to win over a happy worker than over an angry one. For a happiness record book, the sorting number is approximately (N_{happy}-N_{unhappy}-2N_{angry})/N_{total} with sums of corresponding citizens by all the nation (these values are no longer important for the player's score since one could manipulate them too easily). As you can see on the tab, there are six consequent levels of feeling: basic, luxury, buildings, nationality, units, and final. Only the final happiness matters for the further game but different aspects govern changes between intermediate states. As all another citizen-related stuff, the third from the left unhappy worker icon is not connected to that guy that you joined to the city as a migrant at turn 27, there are just four numbers in a city for each feeling level. Most of the code related to city happiness resides in server/city.c. Basic feeling For the basic feeling, there are three effects and two numbers that matter. All the effects are player-specific, not city-specific; the numbers are number of the player's cities, number of the city's citizens and number of workers among the citizens. * "City_Unhappy_Size" - how many workers in a city are content before empire size effects. If the sum of two other effects is not positive, it's the final value. * "Empire_Size_Base" - up to this number of cities, the previous one is not reduced. When it is exceeded, the value is reduced on 1. * "Empire_Size_Step" - if the effect is nonzero, the difference between the number of cities and previous effect is reduced on 1 (as the threshold must be exceeded) and divided (rounding to zero) on this effect value, the result is subtracted from the content value. Now, we have got a number. If it is positive, so many citizens may be content; this value is capped by city size and includes specialists (i.e.: if city size is 4, content number is 2 and 3 citizens are specialists, 2 specialists are content because of an effect, one because of being a specialist, and the worker is not content). If it is negative, minus so many (capped by the present number) workers are angry, but this is ain effect only if angry citizens are enabled. If there are any more workers, they are unhappy. No worker can be happy at this level. Luxury feeling You can get luxuries from artists ("Specialist_Output" effect with "Output_Type", "Luxury", "Local" requirement), trade taxes, wonders ("Output_*" effects with similar requirement, often applied to city center tile) etc. The surplus of city luxuries is used to lift citizens to a higher happiness level, one lift costs civstyle.happy_cost from game.ruleset: * firstly, angry→unhappy; * then, content→happy; * then, unhappy→happy (for double cost); * the last affected unhappy one may become content. So, you can't eliminate unhappiness by luxuries before you make happy all otherwise content citizens. Buildings feeling This level is, in fact, modified from the previous one by just city-specific "Make_Content" effect but its requirements are mostly the city's buildings or player's wonders. Units of the effect's value are spent one by one firstly on angry→unnhappy, then on unhappy→content. Note that the effect "Happiness_To_Gold" does not cancel this or another effect, just duplicates their value into gold production. Nationalities feeling If there are citizens in the city that are of a nation you are currently at war with, they don't like it. You get one fine unit for "Enemy_Citizen_Unhappy_Pct" city-specific effect value percentage of such citizens (rounding down). The fine is applied in order: * firstly, content→unhappy; * then, happy→unhappy (for 2 units); * the last affected happy one may become content. This level does not increase angry workers count. Units feeling Firstly, city martial law counter is calculated: up to effect "Martial_Law_Max" military units deployed at the city center potentially make "Martial_Law_Each" units content per one of them. (Military units are ones without "NonMil" type flag.) This value is firstly spent on angry→unhappy, then on unhappy→content, whatever remains is lost. Then, each agressively deployed (or having type flag "FieldUnit") unit is tested for its happiness upkeep defined by unit type and effects mainly bound to the current government, reduced by "Make_Content_Mil_Per" effect (down to 0); the upkeeps ("angry faces") are summed up and from the sum is subtracted "Make_Content_Mil" effect (result down to 0, angry faces within free upkeep are not shown in the city dialog). The result works for the same conversions as nationalities unhappiness: * firstly, content→unhappy; * then, happy→unhappy (for 2); * the last affected happy one may become content. It does not produce angry units (but in further game versions maybe...). Final (wonders) feeling At this final stage the effects work that are mostly provided by wonders, in this order: * "Make_Happy" - value spent on firstly content→happy, then (for 2) unhappy→happy, what remained is kept. * "No_Unhappy" - if positive, remaining unhappy and angry citizens all become content; * "Force_Content" - the value is added to the remnant of "Make_Happy" effect, and the result is spent on angry→unhappy, then unhappy→content. That means, if we have angry citizens at the beginning of this stage, they will get content at best. Category:Manuals